Skip to content

🛡️ Sentinel: [LOW] nightly backup drops the Jellyfin webhook secret - #370

Merged
Randomname653 merged 1 commit into
mainfrom
sentinel/backup-webhook-secret
Nov 28, 2026
Merged

Randomname653 merged 1 commit into
mainfrom
sentinel/backup-webhook-secret

Conversation

@Randomname653

Copy link
Copy Markdown
Owner

Problem

connection.backup_modes() and the 1.2 CHANGELOG say the nightly backup carries no tokens; that's why the 0640 BACKUP_GROUP_READABLE mode is safe to offer. scheduler._strip_secrets only blanks token columns (users.plex_token, sessions.*). The Jellyfin webhook's shared secret (app_state key jellyfin_hook_secret, the only credential on POST /api/jellyfin/webhook) is a row, so it was copied into every backup unchanged.

Evidence: on the app's migrated database (app_db()), with the secret set and a backup copy run through _strip_secrets, the row was still there ([('S3CRET-…',)]) and its bytes were in the file.

Severity LOW: anyone who can read a backup (the app's group when 0640, or a copy taken off the share) can send authenticated webhook posts. A post is only a hint that triggers a rate-limited re-read with the API key. Nothing is written unless Jellyfin confirms a recent play. So the only harm is breaking the stated invariant, plus a small amount of extra traffic to Jellyfin.

Change

  • _SECRET_STATE_KEYS = ("jellyfin_hook_secret",) in scheduler.py; _strip_secrets deletes those app_state rows in the copy. secure_delete is already on, so the bytes are overwritten.
  • The rest of app_state is untouched.

Measured effect / proof

Same reproduction after the change: after strip: [], raw bytes contain secret: False.

Tests

tests/test_backup_perms.py adds an app_state table with the secret and one ordinary row to its hand-made live DB:

  • before: 13 passed, 2 failed (the Jellyfin webhook secret is not in the backup…, ...nor its bytes)
  • after: 16 passed, 0 failed. This includes a drift guard: jellyfin_hook.SECRET_KEY in scheduler._SECRET_STATE_KEYS, so renaming the key can't make the strip silently miss it.

Full battery: 356/357 green. The one failure is test_enrichment_status_perf.py, which fails the same way on untouched main in this sandbox (SQLite 3.45.1 picks another plan) and passes in CI.

Risk & edge cases

  • Restore from a backup: the webhook route stays off (401, the existing "no secret" path) until the admin opens the setup card again. That creates a new secret to paste into the plugin. This matches how stripped Plex tokens already make each member sign in once.
  • Old databases without app_state: skipped (if "app_state" in tables).
  • The live database is untouched; only the copy changes.

Duplicate check

Searched: PRs for strip_secrets, webhook secret, jellyfin secret backup (only #265, the original Jellyfin feature); git log --oneline -300 (backup commits ce4ff43 / f5abf99 cover columns only); open PRs and branches right before pushing (#366–#369, unrelated).


Generated by Claude Code

The backup's promise is 'no tokens inside' (it is what makes the 0640
BACKUP_GROUP_READABLE mode safe to offer), but _strip_secrets only blanked
token columns; the webhook's shared secret is an app_state row and was
copied verbatim. Delete that row in the copy (secure_delete is already on);
a restore leaves the route off until the admin's next look at the setup
card makes a new secret.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014GBDVBSiv59ZWfET13xFYp
@Randomname653 Randomname653 mentioned this pull request Nov 28, 2026
@Randomname653
Randomname653 merged commit e00071a into main Nov 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants